import type { Feature, Point, GeoJsonProperties } from 'geojson'
import type { Waypoint } from './types'
import type { SymbolFeature } from '@/map'
import { highLightProperties } from '@/map/highlights'

export function waypoint2Feature<G extends GeoJsonProperties>(
  wpt: Waypoint,
  properties: G
): Feature<Point, G> {
  return {
    type: 'Feature',
    geometry: {
      type: 'Point',
      coordinates: [wpt.location.lng, wpt.location.lat]
    },
    properties
  }
}

export function highLightWaypointFeatures(wpt: Waypoint) {
  return { symbol: [highLightWaypointFeature(wpt)] }
}

export function highLightWaypointFeature(wpt: Waypoint): SymbolFeature {
  const p = highLightProperties.symbol.primary(wpt.id)
  return waypoint2Feature(wpt, p)
}
